package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.Reservation;
import com.zzyl.vo.ReservationVo;
import com.zzyl.vo.TimeCountVo;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface CustomerReservationMapper {
    /**
     * 统计该用户剩余的取消次数
     * @param startTime
     * @param endTime
     * @param userId
     * @return
     */
    Integer getCancelledReservationCount(LocalDateTime startTime, LocalDateTime endTime, String userId);

    void insert(Reservation reservation);

    Page<ReservationVo> selectPage(Integer status);

    /**
     * 更新
     * @param reservation
     */
    void update(Reservation reservation);

    /**
     * 统计一天当中每个时段的预约剩余量
     * @param startTime
     * @param endTime
     * @return
     */
    List<TimeCountVo> getRemainReservationCount(LocalDateTime startTime, LocalDateTime endTime);

    /**
     * 根据id查询当前预约信息
     * @param id
     * @return
     */
    @Select("select * from reservation where id =#{id}")
    Reservation getById(Long id);

    /**
     * 拿到所有的Id
     * @return
     */
    @Select("select id from reservation")
    List<Long> getAllIds();
}
